package ycj.learn.spring.bean;

import ycj.learn.spring.common.Person;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Test01  {

    @Test
    public void getBean() {
        ApplicationContext context = new AnnotationConfigApplicationContext(ConfigBeans01.class);
        Person person = context.getBean(Person.class);
        System.out.println(person.toString());
    }

    /**
     * 获取到容器的bean的名字
     */
    @Test
    public void getDefinationNames() {
        ApplicationContext context = new AnnotationConfigApplicationContext(ConfigBeans01.class);

        String[] names = context.getBeanDefinitionNames();

        for (String name : names) {
            System.out.println(name);
        }
    }
}
